package com.pwx.student.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pwx.student.common.ResponseResult;
import com.pwx.student.entity.RcTeacher;
import com.pwx.student.dao.RcTeacherMapper;
import com.pwx.student.service.IRcTeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pwx.student.vo.input.CourseInputVo;
import com.pwx.student.vo.output.StudentScoreOutputVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author saber
 * @since 2022-10-24
 */
@Service
public class RcTeacherServiceImpl extends ServiceImpl<RcTeacherMapper, RcTeacher> implements IRcTeacherService {

    @Autowired
    private RcTeacherMapper teacherMapper;

    @Override
    public ResponseResult getStudentScore(CourseInputVo inputVo) {
        RcTeacher teacher = teacherMapper.selectOne(new QueryWrapper<RcTeacher>()
                .eq("teacher_id", inputVo.getUserId()));
        if (teacher==null){
            return ResponseResult.createFail("该教师不存在");
        }
        PageHelper.startPage(inputVo.getIndex(),8);
        List<StudentScoreOutputVo> voList = teacherMapper.getStudentScore(inputVo);
        PageInfo<StudentScoreOutputVo> info = new PageInfo<>(voList);

        return ResponseResult.createSuccess(info);
    }
}
